
import { post } from '../http'
import store from '@/store'

//新增订单
export const addOrEditOrderInfo = ({

  cmtContractNo, //合同号

  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型

  // adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式

  adcSAddress,//发货地地址
  odcDArea,//收货地区县
  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Attorney: {
            cmtContractNo: cmtContractNo,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attCltId: attCltId,
            attCltName,
            attCEtpId,
            attRemark,
            attCreator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,

          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId: attCltId,
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            creator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: {
            gdsName,
            gdsType,
            gdsQuantity,
            gdsWeight,
            gdsVolumn,
            gdsLength: '1',
            gdsRemark,
            gdsPrice,
            creator: store.state.user.USR_CODE_DX_H
          }
        }
      }
    }
  })
}

//修改
export const EditOrderInfo = ({
  uuid,
  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea, // 发货地区县
  adcSAddress,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  odcDArea,//收货地区县
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型要求

  // adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式


  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Attorney: {
            uuid,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attCltId: attCltId.toString(),
            attCltName,
            attCEtpId,
            attRemark,
            adcSAddress,
            attCreator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId: attCltId.toString(),
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            creator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            odcSArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: {
            gdsName,
            gdsType,
            gdsQuantity,
            gdsWeight,
            gdsVolumn,
            gdsLength: '1',
            gdsRemark,
            gdsPrice,
            attLstmodifier: store.state.user.USR_CODE_DX_H
          }
        }
      }
    }
  })
}

//订单取消
export const cancleOrderInfo = ({
  uuid, attCode, cmtContractNo
}) => {
  return post('/FTKJWLHYPT/transoprt/cancleOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          cmtContractNo,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attCode,
          attLstmodifier: store.state.user.USR_CODE_DX_H,
          attStatus: 'DDQX'
        }
      }
    }
  })
}
//查询
export const orderInfo = ({
  attCode,
  cmtContractNo,
  attStatus,
  attCreatetimeStart,
  attCreatetimeEnd,
  PageIndex,
  PageSize
}) => {
  return post('/FTKJWLHYPT/transoprt/supplierOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attCode,
          cmtContractNo,
          attStatus,
          attCreatetimeStart,
          attCreatetimeEnd
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}


//订单状态查询
export const orderOperaInfo = ({
  attUuid
}) => {
  return post('/FTKJWLHYPT/transoprt/orderOperaInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attUuid,
          optEtpId: store.state.user.FLT_UUID_DX_H,
        }
      }
    }
  })
}

//订单状态查询
export const getorderOperaInfo = ({
  optOrdcode
}) => {
  return post('/FTKJWLHYPT/frtOrder/getOperationservice', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          optOrdcode,
        }
      }
    }
  })
}


//订单审核  订单拒绝  取消审核
export const auditOrder = ({
  uuid,
  attCode,
  attStatus,
  attAuditdiffering
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attStatus,  //YSH,SHJJ,QXSH，  YFB，CS
          attAuditor: store.state.user.USR_CODE_DX_H,
          attCode,
          attAuditdiffering
        }
      }
    }
  })
}
//订单发布
export const releaseOrder = ({
  uuid,
  attCode,
  attStatus,
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attStatus,  //YSH,SHJJ,QXSH，  YFB，CS
          attCode,
          attAuditor: store.state.user.USR_CODE_DX_H
        }
      }
    }
  })
}

//订单批量发布
export const updateMore = (data) => {
  return post('/FTKJWLHYPT/transoprt/bulkUpdate', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          list: data.list,
          stuas: data.stuas,
          laster: store.state.user.USR_CODE_DX_H
        }
      }
    }
  })
}


export const queryListData = () => {
  return post('/FTKJWLHYPT/transoprt/queryListData', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H
        }
      }
    }
  })
}

export const queryUserData = ({
  nowDay,
  beforeDay
}) => {
  return post('/FTKJWLHYPT/transoprt/queryUserData', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          adcEtpId: store.state.user.FLT_UUID_DX_H,
          nowDay,
          beforeDay
        }
      }
    }
  })
}


export const queryBarGraphThree = () => {
  return post('/FTKJWLHYPT/transoprt/queryBarGraphThree', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
        }
      }
    }
  })
}

export const queryBarGraphThreeA = ({ nowDay }) => {
  return post('/FTKJWLHYPT/transoprt/queryBarGraphThreeA', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          adcEtpId: store.state.user.FLT_UUID_DX_H,
          nowDay
        }
      }
    }
  })
}

export const queryLineChart = ({ nowDay }) => {
  return post('/FTKJWLHYPT/transoprt/queryLineChart', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          adcEtpId: store.state.user.FLT_UUID_DX_H,
          nowDay
        }
      }
    }
  })
}

//查询统计中的订单信息查询
export const orderInfoH = ({
  attCode,
  attStatus,
  attCreatetimeStart,
  attCreatetimeEnd,
  PageIndex,
  PageSize
}) => {
  return post('/FTKJWLHYPT/transoprt/orderInfoById', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attCode,
          attStatus,
          attCreatetimeStart,
          attCreatetimeEnd
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}

export const queryWorkbenchChart = ({
  times
}) => {
  return post('/FTKJWLHYPT/base/queryWorkbenchChart', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId: store.state.user.DPTID_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          times
        }
      }
    }
  })
}


export const queryWorkbenchChartForMoney = ({
  times
}) => {
  return post('/FTKJWLHYPT/base/queryWorkbenchChartForMoney', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId: store.state.user.DPTID_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          times
        }
      }
    }
  })
}
export const queryService = (
  data
) => {
  return post('/FTKJWLHYPT/system/gysFinancialService', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {

          companyId: data.companyId

        }
      }
    }
  })
}
export const updateService = (
  data
) => {
  return post('/FTKJWLHYPT/system/updateFinancialService', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid: data.uuid,
          status: data.status
        }
      }
    }
  })
}


export const queryWorkbenchChartChargeBillList = ({
  startTime,
  endTime,
  PageIndexs,
  PageSizes
}) => {
  return post('/FTKJWLHYPT/base/queryWorkbenchChartChargeBillList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId: store.state.user.DPTID_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          startTime,
          endTime
        }
      },
      PageIndex: {
        FTKJWLHYPT: PageIndexs
      },
      PageSize: {
        FTKJWLHYPT: PageSizes
      }
    }
  })
}


